package backed.repository;

import backed.entity.EcoActionPlan;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface EcoActionPlanRepository extends JpaRepository<EcoActionPlan, Long> {

    /**
     * 根据用户ID查找环保行动方案
     */
    List<EcoActionPlan> findByUserId(Long userId);

    /**
     * 根据用户ID和状态查找环保行动方案
     */
    List<EcoActionPlan> findByUserIdAndStatus(Long userId, String status);

    /**
     * 查找用户的最新环保行动方案
     */
    Optional<EcoActionPlan> findFirstByUserIdOrderByCreateTimeDesc(Long userId);
}